home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 361_01 / filex.c < prev    next >
C/C++ Source or Header  |  1991-09-18  |  1KB  |  44 lines

  1.  
  2. /* Filex.c --> A Collection of File Name Tools
  3.  *
  4.  * Author: J.Ekwall                                     13 September 91
  5.  *
  6.  * Copyrighted to the Public Domain.  Unlimited Distribution Authorized.
  7.  *
  8.  * User Assumes All Risks/Liabilities.
  9.  *
  10.  * Last Update: 13 September 91/EK
  11.  */
  12.  
  13. #include <dir.h>
  14. #include <stdio.h>
  15. #include <stdek.h>
  16. #include <gadgets.h>
  17. #include <string.h>
  18.  
  19. char *BaseName(char *FileName)
  20. {
  21.     char *tp1;
  22.     
  23.     if ((tp1 = strrchr(FileName, BKSL)) != NULL) return ++tp1;
  24.     if ((tp1 = strrchr(FileName, COLON)) != NULL) return ++tp1;
  25.     return FileName;
  26. }
  27.  
  28. long GetFileSize(char *FileName)
  29. {
  30.     struct ffblk fb;
  31.  
  32.     if(!findfirst(FileName, &fb, 0)) return (fb.ff_fsize); else  return (-1);
  33. }
  34.  
  35. void NewExt(char *Old, char *New, char *Ext)
  36. {
  37.     char *tp1;
  38.  
  39.     strcpy(New, Old); if ((tp1 = strrchr(New, DOT)) != NULL) *tp1 = NULL;
  40.     if (!*Ext) return;
  41.     strcat(New, "."); if (*(tp1 = Ext) IS DOT) tp1++; strcat(New, tp1);
  42. }
  43.  
  44.